package me.zk.practice1.s;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author zhangkai
 * @date 2023/7/15 11:53
 */
public class LS_Offer_50 {
    public char firstUniqChar(String s) {
        if (s.equals("")) {
            return ' ';
        }
        char[] chars = s.toCharArray();
        Map<Character,Integer> map = new LinkedHashMap<>();
        for (char c : chars) {
            map.put(c,map.getOrDefault(c,0)+1);
        }
        for (char c : map.keySet()) {
           if (map.get(c) ==1) {
               return c;
           }
        }
        return ' ';
    }
}
